plot.title = element_text(size=rel(1.8), hjust=0))
ggsave(file=paste0(getwd(), "/figures/figure2.pdf"), width=11, height=10)
# Figure 3 - from model 5
m5eff <- effect("NHHI*hegpolity", model5.man, xlevels = list(NHHI = c(0, .2, .4, .6, .8), hegpolity = c(-10, 0, 10)), multiline = TRUE)
forfig3 <- as.data.frame(m5eff)
forfig3$hegpolity.fig[forfig3$hegpolity == -10]  <- "Regional Power Polity = -10"
forfig3$hegpolity.fig[forfig3$hegpolity == 0]  <- "Regional Power Polity = 0"
forfig3$hegpolity.fig[forfig3$hegpolity == 10]  <- "Regional Power Polity = 10"
ggplot(forfig3, aes(x = NHHI, y = fit)) +
geom_ribbon(aes(ymin = lower, ymax = upper, linetype=NA), alpha = .8)  +
geom_line(size = .5, type = 1) + xlab("Regional CINC NHHI") + ylab("log Trade t+1") +
# ggtitle("Predicted value of regional trade proportion with 95% confidence bounds") +
facet_wrap(~ hegpolity.fig) +
theme_bw() +
theme(axis.text.y = element_text(hjust=0, size=rel(1.1)),
panel.grid.major.y = element_line(size=0.25, colour="grey80",
linetype="dashed"),
axis.text.x = element_text(hjust = 1),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks = element_blank(),
plot.title = element_text(size=rel(1.8), hjust=0))
ggsave(file=paste0(getwd(), "/figures/figure3.pdf"), width=11, height=10)
# Figure 3 - from model 5
m5eff <- effect("NHHI*hegpolity", model5.man, xlevels = list(NHHI = c(0, .2, .4, .6, .8), hegpolity = c(-10, 0, 10)), multiline = TRUE)
forfig3 <- as.data.frame(m5eff)
forfig3$hegpolity.fig[forfig3$hegpolity == -10]  <- "Regional Power Polity = -10"
forfig3$hegpolity.fig[forfig3$hegpolity == 0]  <- "Regional Power Polity = 0"
forfig3$hegpolity.fig[forfig3$hegpolity == 10]  <- "Regional Power Polity = 10"
ggplot(forfig3, aes(x = NHHI, y = fit)) +
geom_ribbon(aes(ymin = lower, ymax = upper, linetype=NA), alpha = .8)  +
geom_line(size = .5, linetype = 1) + xlab("Regional CINC NHHI") + ylab("log Trade t+1") +
# ggtitle("Predicted value of regional trade proportion with 95% confidence bounds") +
facet_wrap(~ hegpolity.fig) +
theme_bw() +
theme(axis.text.y = element_text(hjust=0, size=rel(1.1)),
panel.grid.major.y = element_line(size=0.25, colour="grey80",
linetype="dashed"),
axis.text.x = element_text(hjust = 1),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks = element_blank(),
plot.title = element_text(size=rel(1.8), hjust=0))
ggsave(file=paste0(getwd(), "/figures/figure3.pdf"), width=11, height=10)
# Appendix figure 1
m1reff <- effect("NHHI*hegpolity", model1.re, xlevels = list(NHHI = c(0, .2, .4, .6, .8), hegpolity = c(-10, 0, 10)), multiline = TRUE)
forfigA1 <- as.data.frame(m1reff)
forfigA1$hegpolity.fig[forfigA1$hegpolity == -10]  <- "Regional Power Polity = -10"
forfigA1$hegpolity.fig[forfigA1$hegpolity == 0]  <- "Regional Power Polity = 0"
forfigA1$hegpolity.fig[forfigA1$hegpolity == 10]  <- "Regional Power Polity = 10"
ggplot(forfigA1, aes(x = NHHI, y = fit)) +
geom_ribbon(aes(ymin = lower, ymax = upper, linetype=NA), alpha = .8)  +
geom_line(size = .5, linetype = 1) + xlab("Regional CINC NHHI") + ylab("log Trade t+1") +
# ggtitle("Predicted value of intra-trade with 95% confidence bounds") +
facet_wrap(~ hegpolity.fig) +
theme_bw() +
theme(axis.text.y = element_text(hjust=0, size=rel(1.1)),
panel.grid.major.y = element_line(size=0.25, colour="grey80",
linetype="dashed"),
axis.text.x = element_text(hjust = 1),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks = element_blank(),
plot.title = element_text(size=rel(1.8), hjust=0))
ggsave(file=paste0(getwd(), "/figures/figureA1.pdf"), width=11, height=10)
# Appendix figure 2
m3reff <- effect("NHHI*hegpolity", model3.re, xlevels = list(NHHI = c(0, .2, .4, .6, .8), hegpolity = c(-10, 0, 10)), multiline = TRUE)
forfigA2 <- as.data.frame(m3reff)
forfigA2$hegpolity.fig[forfigA2$hegpolity == -10]  <- "Regional Power Polity = -10"
forfigA2$hegpolity.fig[forfigA2$hegpolity == 0]  <- "Regional Power Polity = 0"
forfigA2$hegpolity.fig[forfigA2$hegpolity == 10]  <- "Regional Power Polity = 10"
ggplot(forfigA2, aes(x = NHHI, y = fit)) +
geom_ribbon(aes(ymin = lower, ymax = upper, linetype=NA), alpha = .8)  +
geom_line(size = .5, linetype = 1) + xlab("Regional CINC NHHI") + ylab("log Trade t+1") +
# ggtitle("Predicted value of inter-region trade with 95% confidence bounds") +
facet_wrap(~ hegpolity.fig) +
theme_bw() +
theme(axis.text.y = element_text(hjust=0, size=rel(1.1)),
panel.grid.major.y = element_line(size=0.25, colour="grey80",
linetype="dashed"),
axis.text.x = element_text(hjust = 1),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks = element_blank(),
plot.title = element_text(size=rel(1.8), hjust=0))
ggsave(file=paste0(getwd(), "/figures/figureA2.pdf"), width=11, height=10)
# Appendix figure 3
m5reff <- effect("NHHI*hegpolity", model5.re, xlevels = list(NHHI = c(0, .2, .4, .6, .8), hegpolity = c(-10, 0, 10)), multiline = TRUE)
forfigA3 <- as.data.frame(m5reff)
forfigA3$hegpolity.fig[forfigA3$hegpolity == -10]  <- "Regional Power Polity = -10"
forfigA3$hegpolity.fig[forfigA3$hegpolity == 0]  <- "Regional Power Polity = 0"
forfigA3$hegpolity.fig[forfigA3$hegpolity == 10]  <- "Regional Power Polity = 10"
ggplot(forfigA3, aes(x = NHHI, y = fit)) +
geom_ribbon(aes(ymin = lower, ymax = upper, linetype=NA), alpha = .8)  +
geom_line(size = .5, linetype = 1) + xlab("Regional CINC NHHI") + ylab("log Trade t+1") +
# ggtitle("Predicted value of region trade proportion with 95% confidence bounds") +
facet_wrap(~ hegpolity.fig) +
theme_bw() +
theme(axis.text.y = element_text(hjust=0, size=rel(1.1)),
panel.grid.major.y = element_line(size=0.25, colour="grey80",
linetype="dashed"),
axis.text.x = element_text(hjust = 1),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks = element_blank(),
plot.title = element_text(size=rel(1.8), hjust=0))
ggsave(file=paste0(getwd(), "/figures/figureA3.pdf"), width=11, height=10)
# Appendix figure 4
m4eff <- effect("NHHI*hegpolity", model1.man, xlevels = list(hegpolity = c(-10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10),
NHHI = c(.2, .5, .8)), multiline = TRUE)
forfig4p <- as.data.frame(m4eff)
forfig4p$NHHI.fig[forfig4p$NHHI == .2]  <- "Regional CINC NHHI = .2"
forfig4p$NHHI.fig[forfig4p$NHHI == .5]  <- "Regional CINC NHHI = .5"
forfig4p$NHHI.fig[forfig4p$NHHI == .8]  <- "Regional CINC NHHI = .8"
ggplot(forfig4p, aes(x = hegpolity, y = fit)) +
geom_ribbon(aes(ymin = lower, ymax = upper, linetype=NA), alpha = .8)  +
geom_line(size = .5, linetype = 1) + xlab("Regional power Polity") + ylab("log Trade t+1") +
# ggtitle("Predicted value of intra-region trade with 95% confidence bounds") +
facet_wrap(~ NHHI.fig) +
theme_bw() +
theme(axis.text.y = element_text(hjust=0, size=rel(1.1)),
panel.grid.major.y = element_line(size=0.25, colour="grey80",
linetype="dashed"),
axis.text.x = element_text(hjust = 1),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks = element_blank(),
plot.title = element_text(size=rel(1.8), hjust=0))
ggsave(file=paste0(getwd(), "/figures/figure1p.pdf"), width=11, height=10)
# Appendix Figure 5
m5eff <- effect("NHHI*hegpolity", model3.man, xlevels = list(hegpolity = c(-10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10),
NHHI = c(.2, .5, .8)), multiline = TRUE)
forfig5p <- as.data.frame(m5eff)
forfig5p$NHHI.fig[forfig5p$NHHI == .2]  <- "Regional CINC NHHI = .2"
forfig5p$NHHI.fig[forfig5p$NHHI == .5]  <- "Regional CINC NHHI = .5"
forfig5p$NHHI.fig[forfig5p$NHHI == .8]  <- "Regional CINC NHHI = .8"
ggplot(forfig2p, aes(x = hegpolity, y = fit)) +
geom_ribbon(aes(ymin = lower, ymax = upper, linetype=NA), alpha = .8)  +
geom_line(size = .5, linetype = 1) + xlab("Regional power Polity") + ylab("log Trade t+1") +
# ggtitle("Predicted value of intra-region trade with 95% confidence bounds") +
facet_wrap(~ NHHI.fig) +
theme_bw() +
theme(axis.text.y = element_text(hjust=0, size=rel(1.1)),
panel.grid.major.y = element_line(size=0.25, colour="grey80",
linetype="dashed"),
axis.text.x = element_text(hjust = 1),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks = element_blank(),
plot.title = element_text(size=rel(1.8), hjust=0))
ggsave(file=paste0(getwd(), "/figures/figure2p.pdf"), width=11, height=10)
# Appendix Figure 6
m6eff <- effect("NHHI*hegpolity", model5.man, xlevels = list(hegpolity = c(-10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10),
NHHI = c(.2, .5, .8)), multiline = TRUE)
forfig6p <- as.data.frame(m6eff)
forfig6p$NHHI.fig[forfig6p$NHHI == .2]  <- "Regional CINC NHHI = .2"
forfig6p$NHHI.fig[forfig6p$NHHI == .5]  <- "Regional CINC NHHI = .5"
forfig6p$NHHI.fig[forfig6p$NHHI == .8]  <- "Regional CINC NHHI = .8"
ggplot(forfig3p, aes(x = hegpolity, y = fit)) +
geom_ribbon(aes(ymin = lower, ymax = upper, linetype=NA), alpha = .8)  +
geom_line(size = .5, linetype = 1) + xlab("Regional power Polity") + ylab("log Trade t+1") +
# ggtitle("Predicted value of intra-region trade with 95% confidence bounds") +
facet_wrap(~ NHHI.fig) +
theme_bw() +
theme(axis.text.y = element_text(hjust=0, size=rel(1.1)),
panel.grid.major.y = element_line(size=0.25, colour="grey80",
linetype="dashed"),
axis.text.x = element_text(hjust = 1),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks = element_blank(),
plot.title = element_text(size=rel(1.8), hjust=0))
ggsave(file=paste0(getwd(), "/figures/figure3p.pdf"), width=11, height=10)
# Appendix figure 7 - Graph for dyad intra-region trade
m1deffr <- effect("NHHI1*hegpolity1", model1dr, xlevels = list(NHHI1 = c(0, .2, .4, .6, .8), hegpolity1 = c(-10, 0, 10)), multiline = TRUE)
forfigA7 <- as.data.frame(m1deffr)
forfigA7$hegpolity1.fig[forfigA7$hegpolity1 == -10]  <- "Regional Power Polity = -10"
forfigA7$hegpolity1.fig[forfigA7$hegpolity1 == 0]  <- "Regional Power Polity = 0"
forfigA7$hegpolity1.fig[forfigA7$hegpolity1 == 10]  <- "Regional Power Polity = 10"
ggplot(forfigA7, aes(x = NHHI1, y = fit)) +
geom_ribbon(aes(ymin = lower, ymax = upper, linetype=NA), alpha = .8)  +
geom_line(size = .5, linetype = 1) + xlab("Regional CINC NHHI") + ylab("log Exports t+1") +
# ggtitle("Predicted value of intra-region dyadic trade with 95% confidence bounds") +
facet_wrap(~ hegpolity1.fig) +
theme_bw() +
theme(axis.text.y = element_text(hjust=0, size=rel(1.1)),
panel.grid.major.y = element_line(size=0.25, colour="grey80",
linetype="dashed"),
axis.text.x = element_text(hjust = 1),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks = element_blank(),
plot.title = element_text(size=rel(1.8), hjust=0))
ggsave(file=paste0(getwd(), "/figures/figureA7.pdf"), width=11, height=10)
# Appendix Figure 6
m6eff <- effect("NHHI*hegpolity", model5.man, xlevels = list(hegpolity = c(-10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10),
NHHI = c(.2, .5, .8)), multiline = TRUE)
forfig6p <- as.data.frame(m6eff)
forfig6p$NHHI.fig[forfig6p$NHHI == .2]  <- "Regional CINC NHHI = .2"
forfig6p$NHHI.fig[forfig6p$NHHI == .5]  <- "Regional CINC NHHI = .5"
forfig6p$NHHI.fig[forfig6p$NHHI == .8]  <- "Regional CINC NHHI = .8"
ggplot(forfig6p, aes(x = hegpolity, y = fit)) +
geom_ribbon(aes(ymin = lower, ymax = upper, linetype=NA), alpha = .8)  +
geom_line(size = .5, linetype = 1) + xlab("Regional power Polity") + ylab("log Trade t+1") +
# ggtitle("Predicted value of intra-region trade with 95% confidence bounds") +
facet_wrap(~ NHHI.fig) +
theme_bw() +
theme(axis.text.y = element_text(hjust=0, size=rel(1.1)),
panel.grid.major.y = element_line(size=0.25, colour="grey80",
linetype="dashed"),
axis.text.x = element_text(hjust = 1),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks = element_blank(),
plot.title = element_text(size=rel(1.8), hjust=0))
ggsave(file=paste0(getwd(), "/figures/figureA6.pdf"), width=11, height=10)
# Appendix Figure 5
m5eff <- effect("NHHI*hegpolity", model3.man, xlevels = list(hegpolity = c(-10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10),
NHHI = c(.2, .5, .8)), multiline = TRUE)
forfig5p <- as.data.frame(m5eff)
forfig5p$NHHI.fig[forfig5p$NHHI == .2]  <- "Regional CINC NHHI = .2"
forfig5p$NHHI.fig[forfig5p$NHHI == .5]  <- "Regional CINC NHHI = .5"
forfig5p$NHHI.fig[forfig5p$NHHI == .8]  <- "Regional CINC NHHI = .8"
ggplot(forfig2p, aes(x = hegpolity, y = fit)) +
geom_ribbon(aes(ymin = lower, ymax = upper, linetype=NA), alpha = .8)  +
geom_line(size = .5, linetype = 1) + xlab("Regional power Polity") + ylab("log Trade t+1") +
# ggtitle("Predicted value of intra-region trade with 95% confidence bounds") +
facet_wrap(~ NHHI.fig) +
theme_bw() +
theme(axis.text.y = element_text(hjust=0, size=rel(1.1)),
panel.grid.major.y = element_line(size=0.25, colour="grey80",
linetype="dashed"),
axis.text.x = element_text(hjust = 1),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks = element_blank(),
plot.title = element_text(size=rel(1.8), hjust=0))
ggsave(file=paste0(getwd(), "/figures/figureA5.pdf"), width=11, height=10)
# Appendix figure 4
m4eff <- effect("NHHI*hegpolity", model1.man, xlevels = list(hegpolity = c(-10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10),
NHHI = c(.2, .5, .8)), multiline = TRUE)
forfig4p <- as.data.frame(m4eff)
forfig4p$NHHI.fig[forfig4p$NHHI == .2]  <- "Regional CINC NHHI = .2"
forfig4p$NHHI.fig[forfig4p$NHHI == .5]  <- "Regional CINC NHHI = .5"
forfig4p$NHHI.fig[forfig4p$NHHI == .8]  <- "Regional CINC NHHI = .8"
ggplot(forfig4p, aes(x = hegpolity, y = fit)) +
geom_ribbon(aes(ymin = lower, ymax = upper, linetype=NA), alpha = .8)  +
geom_line(size = .5, linetype = 1) + xlab("Regional power Polity") + ylab("log Trade t+1") +
# ggtitle("Predicted value of intra-region trade with 95% confidence bounds") +
facet_wrap(~ NHHI.fig) +
theme_bw() +
theme(axis.text.y = element_text(hjust=0, size=rel(1.1)),
panel.grid.major.y = element_line(size=0.25, colour="grey80",
linetype="dashed"),
axis.text.x = element_text(hjust = 1),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks = element_blank(),
plot.title = element_text(size=rel(1.8), hjust=0))
ggsave(file=paste0(getwd(), "/figures/figureA4.pdf"), width=11, height=10)
## Dyad model graphs ##
# Appendix figure 7 - Graph for dyad intra-region trade
m1deffr <- effect("NHHI1*hegpolity1", model1dr, xlevels = list(NHHI1 = c(0, .2, .4, .6, .8), hegpolity1 = c(-10, 0, 10)), multiline = TRUE)
forfigA7 <- as.data.frame(m1deffr)
forfigA7$hegpolity1.fig[forfigA7$hegpolity1 == -10]  <- "Regional Power Polity = -10"
forfigA7$hegpolity1.fig[forfigA7$hegpolity1 == 0]  <- "Regional Power Polity = 0"
forfigA7$hegpolity1.fig[forfigA7$hegpolity1 == 10]  <- "Regional Power Polity = 10"
ggplot(forfigA7, aes(x = NHHI1, y = fit)) +
geom_ribbon(aes(ymin = lower, ymax = upper, linetype=NA), alpha = .8)  +
geom_line(size = .5, linetype = 1) + xlab("Regional CINC NHHI") + ylab("log Exports t+1") +
# ggtitle("Predicted value of intra-region dyadic trade with 95% confidence bounds") +
facet_wrap(~ hegpolity1.fig) +
theme_bw() +
theme(axis.text.y = element_text(hjust=0, size=rel(1.1)),
panel.grid.major.y = element_line(size=0.25, colour="grey80",
linetype="dashed"),
axis.text.x = element_text(hjust = 1),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks = element_blank(),
plot.title = element_text(size=rel(1.8), hjust=0))
ggsave(file=paste0(getwd(), "/figures/figureA7.pdf"), width=11, height=10)
m2deffr <- effect("NHHI1*hegpolity1", model2dr, xlevels = list(NHHI1 = c(0, .2, .4, .6, .8), hegpolity1 = c(-10, 0, 10)), multiline = TRUE)
forfigA8 <- as.data.frame(m2deffr)
forfigA8$hegpolity1.fig[forfigA8$hegpolity1 == -10]  <- "Regional Power Polity = -10"
forfigA8$hegpolity1.fig[forfigA8$hegpolity1 == 0]  <- "Regional Power Polity = 0"
forfigA8$hegpolity1.fig[forfigA8$hegpolity1 == 10]  <- "Regional Power Polity = 10"
f8a <- ggplot(forfigA8, aes(x = NHHI1, y = fit)) +
geom_ribbon(aes(ymin = lower, ymax = upper, linetype=NA), alpha = .8)  +
geom_line(size = .5, linetype = 1) + xlab("Regional CINC NHHI") + ylab("log Exports t+1") +
ggtitle("Exporter region") +
facet_wrap(~ hegpolity1.fig) +
theme_bw() +
theme(axis.text.y = element_text(hjust=0, size=rel(1.1)),
panel.grid.major.y = element_line(size=0.25, colour="grey80",
linetype="dashed"),
axis.text.x = element_text(hjust = 1),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks = element_blank(),
plot.title = element_text(size=rel(1.8), hjust=0))
m2deffr2 <- effect("NHHI2*hegpolity2", model2dr, xlevels = list(NHHI2 = c(0, .2, .4, .6, .8), hegpolity2 = c(-10, 0, 10)), multiline = TRUE)
forfigA8B <- as.data.frame(m2deffr2)
forfigA8B$hegpolity2.fig[forfigA8B$hegpolity2 == -10]  <- "Regional Power Polity = -10"
forfigA8B$hegpolity2.fig[forfigA8B$hegpolity2 == 0]  <- "Regional Power Polity = 0"
forfigA8B$hegpolity2.fig[forfigA8B$hegpolity2 == 10]  <- "Regional Power Polity = 10"
f8b <- ggplot(forfigA8B, aes(x = NHHI2, y = fit)) +
geom_ribbon(aes(ymin = lower, ymax = upper, linetype=NA), alpha = .8)  +
geom_line(size = .5, linetype = 1) + xlab("Regional CINC NHHI") + ylab("log Exports t+1") +
ggtitle("Importer region") +
facet_wrap(~ hegpolity2.fig) +
theme_bw() +
theme(axis.text.y = element_text(hjust=0, size=rel(1.1)),
panel.grid.major.y = element_line(size=0.25, colour="grey80",
linetype="dashed"),
axis.text.x = element_text(hjust = 1),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks = element_blank(),
plot.title = element_text(size=rel(1.8), hjust=0))
# Combine figures 8A and 8B
multiplot <- function(..., plotlist=NULL, file, cols=1, layout=NULL) {
require(grid)
# Make a list from the ... arguments and plotlist
plots <- c(list(...), plotlist)
numPlots = length(plots)
# If layout is NULL, then use 'cols' to determine layout
if (is.null(layout)) {
# Make the panel
# ncol: Number of columns of plots
# nrow: Number of rows needed, calculated from # of cols
layout <- matrix(seq(1, cols * ceiling(numPlots/cols)),
ncol = cols, nrow = ceiling(numPlots/cols))
}
if (numPlots==1) {
print(plots[[1]])
} else {
# Set up the page
grid.newpage()
pushViewport(viewport(layout = grid.layout(nrow(layout), ncol(layout))))
# Make each plot, in the correct location
for (i in 1:numPlots) {
# Get the i,j matrix positions of the regions that contain this subplot
matchidx <- as.data.frame(which(layout == i, arr.ind = TRUE))
print(plots[[i]], vp = viewport(layout.pos.row = matchidx$row,
layout.pos.col = matchidx$col))
}
}
}
multiplot(f8a, f8b, cols = 1)
source('~/Library/Mobile Documents/com~apple~CloudDocs/Working folder/II replication/1 main file.R', echo=TRUE)
# Appendix Figure 5
m5eff <- effect("NHHI*hegpolity", model3.man, xlevels = list(hegpolity = c(-10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10),
NHHI = c(.2, .5, .8)), multiline = TRUE)
forfig5p <- as.data.frame(m5eff)
forfig5p$NHHI.fig[forfig5p$NHHI == .2]  <- "Regional CINC NHHI = .2"
forfig5p$NHHI.fig[forfig5p$NHHI == .5]  <- "Regional CINC NHHI = .5"
forfig5p$NHHI.fig[forfig5p$NHHI == .8]  <- "Regional CINC NHHI = .8"
ggplot(forfig5p, aes(x = hegpolity, y = fit)) +
geom_ribbon(aes(ymin = lower, ymax = upper, linetype=NA), alpha = .8)  +
geom_line(size = .5, linetype = 1) + xlab("Regional power Polity") + ylab("log Trade t+1") +
# ggtitle("Predicted value of intra-region trade with 95% confidence bounds") +
facet_wrap(~ NHHI.fig) +
theme_bw() +
theme(axis.text.y = element_text(hjust=0, size=rel(1.1)),
panel.grid.major.y = element_line(size=0.25, colour="grey80",
linetype="dashed"),
axis.text.x = element_text(hjust = 1),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks = element_blank(),
plot.title = element_text(size=rel(1.8), hjust=0))
ggsave(file=paste0(getwd(), "/figures/figureA5.pdf"), width=11, height=10)
# Appendix Figure 6
m6eff <- effect("NHHI*hegpolity", model5.man, xlevels = list(hegpolity = c(-10, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10),
NHHI = c(.2, .5, .8)), multiline = TRUE)
forfig6p <- as.data.frame(m6eff)
forfig6p$NHHI.fig[forfig6p$NHHI == .2]  <- "Regional CINC NHHI = .2"
forfig6p$NHHI.fig[forfig6p$NHHI == .5]  <- "Regional CINC NHHI = .5"
forfig6p$NHHI.fig[forfig6p$NHHI == .8]  <- "Regional CINC NHHI = .8"
ggplot(forfig6p, aes(x = hegpolity, y = fit)) +
geom_ribbon(aes(ymin = lower, ymax = upper, linetype=NA), alpha = .8)  +
geom_line(size = .5, linetype = 1) + xlab("Regional power Polity") + ylab("log Trade t+1") +
# ggtitle("Predicted value of intra-region trade with 95% confidence bounds") +
facet_wrap(~ NHHI.fig) +
theme_bw() +
theme(axis.text.y = element_text(hjust=0, size=rel(1.1)),
panel.grid.major.y = element_line(size=0.25, colour="grey80",
linetype="dashed"),
axis.text.x = element_text(hjust = 1),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks = element_blank(),
plot.title = element_text(size=rel(1.8), hjust=0))
ggsave(file=paste0(getwd(), "/figures/figureA6.pdf"), width=11, height=10)
## Dyad model graphs ##
# Appendix figure 7 - Graph for dyad intra-region trade
m1deffr <- effect("NHHI1*hegpolity1", model1dr, xlevels = list(NHHI1 = c(0, .2, .4, .6, .8), hegpolity1 = c(-10, 0, 10)), multiline = TRUE)
forfigA7 <- as.data.frame(m1deffr)
forfigA7$hegpolity1.fig[forfigA7$hegpolity1 == -10]  <- "Regional Power Polity = -10"
forfigA7$hegpolity1.fig[forfigA7$hegpolity1 == 0]  <- "Regional Power Polity = 0"
forfigA7$hegpolity1.fig[forfigA7$hegpolity1 == 10]  <- "Regional Power Polity = 10"
ggplot(forfigA7, aes(x = NHHI1, y = fit)) +
geom_ribbon(aes(ymin = lower, ymax = upper, linetype=NA), alpha = .8)  +
geom_line(size = .5, linetype = 1) + xlab("Regional CINC NHHI") + ylab("log Exports t+1") +
# ggtitle("Predicted value of intra-region dyadic trade with 95% confidence bounds") +
facet_wrap(~ hegpolity1.fig) +
theme_bw() +
theme(axis.text.y = element_text(hjust=0, size=rel(1.1)),
panel.grid.major.y = element_line(size=0.25, colour="grey80",
linetype="dashed"),
axis.text.x = element_text(hjust = 1),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks = element_blank(),
plot.title = element_text(size=rel(1.8), hjust=0))
ggsave(file=paste0(getwd(), "/figures/figureA7.pdf"), width=11, height=10)
# Appendix figure 8 - two parts
m2deffr <- effect("NHHI1*hegpolity1", model2dr, xlevels = list(NHHI1 = c(0, .2, .4, .6, .8), hegpolity1 = c(-10, 0, 10)), multiline = TRUE)
forfigA8 <- as.data.frame(m2deffr)
forfigA8$hegpolity1.fig[forfigA8$hegpolity1 == -10]  <- "Regional Power Polity = -10"
forfigA8$hegpolity1.fig[forfigA8$hegpolity1 == 0]  <- "Regional Power Polity = 0"
forfigA8$hegpolity1.fig[forfigA8$hegpolity1 == 10]  <- "Regional Power Polity = 10"
f8a <- ggplot(forfigA8, aes(x = NHHI1, y = fit)) +
geom_ribbon(aes(ymin = lower, ymax = upper, linetype=NA), alpha = .8)  +
geom_line(size = .5, linetype = 1) + xlab("Regional CINC NHHI") + ylab("log Exports t+1") +
ggtitle("Exporter region") +
facet_wrap(~ hegpolity1.fig) +
theme_bw() +
theme(axis.text.y = element_text(hjust=0, size=rel(1.1)),
panel.grid.major.y = element_line(size=0.25, colour="grey80",
linetype="dashed"),
axis.text.x = element_text(hjust = 1),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks = element_blank(),
plot.title = element_text(size=rel(1.8), hjust=0))
m2deffr2 <- effect("NHHI2*hegpolity2", model2dr, xlevels = list(NHHI2 = c(0, .2, .4, .6, .8), hegpolity2 = c(-10, 0, 10)), multiline = TRUE)
forfigA8B <- as.data.frame(m2deffr2)
forfigA8B$hegpolity2.fig[forfigA8B$hegpolity2 == -10]  <- "Regional Power Polity = -10"
forfigA8B$hegpolity2.fig[forfigA8B$hegpolity2 == 0]  <- "Regional Power Polity = 0"
forfigA8B$hegpolity2.fig[forfigA8B$hegpolity2 == 10]  <- "Regional Power Polity = 10"
f8b <- ggplot(forfigA8B, aes(x = NHHI2, y = fit)) +
geom_ribbon(aes(ymin = lower, ymax = upper, linetype=NA), alpha = .8)  +
geom_line(size = .5, linetype = 1) + xlab("Regional CINC NHHI") + ylab("log Exports t+1") +
ggtitle("Importer region") +
facet_wrap(~ hegpolity2.fig) +
theme_bw() +
theme(axis.text.y = element_text(hjust=0, size=rel(1.1)),
panel.grid.major.y = element_line(size=0.25, colour="grey80",
linetype="dashed"),
axis.text.x = element_text(hjust = 1),
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks = element_blank(),
plot.title = element_text(size=rel(1.8), hjust=0))
# Combine figures 8A and 8B
multiplot <- function(..., plotlist=NULL, file, cols=1, layout=NULL) {
require(grid)
# Make a list from the ... arguments and plotlist
plots <- c(list(...), plotlist)
numPlots = length(plots)
# If layout is NULL, then use 'cols' to determine layout
if (is.null(layout)) {
# Make the panel
# ncol: Number of columns of plots
# nrow: Number of rows needed, calculated from # of cols
layout <- matrix(seq(1, cols * ceiling(numPlots/cols)),
ncol = cols, nrow = ceiling(numPlots/cols))
}
if (numPlots==1) {
print(plots[[1]])
} else {
# Set up the page
grid.newpage()
pushViewport(viewport(layout = grid.layout(nrow(layout), ncol(layout))))
# Make each plot, in the correct location
for (i in 1:numPlots) {
# Get the i,j matrix positions of the regions that contain this subplot
matchidx <- as.data.frame(which(layout == i, arr.ind = TRUE))
print(plots[[i]], vp = viewport(layout.pos.row = matchidx$row,
layout.pos.col = matchidx$col))
}
}
}
multiplot(f8a, f8b, cols = 1)
ggsave(file=paste0(getwd(), "/figures/figureA8.pdf"), width=11, height=10)
fig8 <- multiplot(f8a, f8b, cols = 1)
ggsave(fig8, file=paste0(getwd(), "/figures/figureA8.pdf"), width=11, height=10)
ggsave(multiplot(f8a, f8b, cols = 1), file=paste0(getwd(), "/figures/figureA8.pdf"), width=11, height=10)
?multiplot
pdf(multiplot(f8a, f8b, cols = 1), file=paste0(getwd(), "/figures/figureA8.pdf"), width=11, height=10))
pdf(multiplot(f8a, f8b, cols = 1), width=11, height=10))
pdf(multiplot(f8a, f8b, cols = 1), width=11, height=10)
?pdf()
multiplot(f8a, f8b, cols = 1)
pdf(filename = paste0(getwd(), "/figures/figureA8.pdf"), width=11, height=10)
multiplot(f8a, f8b, cols = 1)
dev.off()
pdf(filename = paste0(getwd(), "/figures/figureA8.pdf"))
multiplot(f8a, f8b, cols = 1)
dev.off()
pdf(filename = paste0(getwd(), "/figures/figureA8.pdf"))
pdf(file = paste0(getwd(), "/figures/figureA8.pdf"))
multiplot(f8a, f8b, cols = 1)
dev.off()
pdf(file = paste0(getwd(), "/figures/figureA8.pdf"), width=11, height=10)
multiplot(f8a, f8b, cols = 1)
dev.off()
source('~/Library/Mobile Documents/com~apple~CloudDocs/Working folder/II replication/1 main file.R', echo=TRUE)
QOGT <- read.dta(file = "http://www.qogdata.pol.gu.se/data/qog_std_ts_jan16.dta")
source('~/Documents/Dropbox/Regional Hegemony/II acceptance/II replication/1 main file.R', echo=TRUE)
